<?php


namespace app\student\controller;

use app\student\model\teacherBaseModel;
use think\Controller;

class TeacherBase extends TeacherLogin
{
    public function teacherBase()
    {
        $teacher['t.id'] = session('t_name.id');


        $result = teacherBaseModel::teacherBaseModel($teacher);
        //var_dump($teacher,$result);

        $this->assign('result',$result);
        return $this->fetch('Login/teacherBase');
    }

    //给学生打分的方法
    public function studentAchievement()
    {
            $teacher_id = $this->request->get();
            //var_dump($teacher_id);die;
            //通过老师id查出他下面的学生和所对应的科目并且进行打分
            $result = teacherBaseModel::selectStudentCourse($teacher_id);
           // var_dump($result);
            if($result)
            {
                $this->assign('result',$result);

                return $this->fetch('Login/studentAchievement');
            }else{
                return $this->error('打分失败','/student/Teacher_Base/TeacherBase');
            }

    }


    public function achievement()
    {
        if($this->request->isPost())
        {
            $achievement = $this->request->post();
            //var_dump($achievement);die;
            $result = teacherBaseModel::achievement($achievement);
            if($result)
            {
                return $this->success('打分成功','/student/Teacher_Base/TeacherBase');
            }else{
                return $this->error('打分失败','/student/Teacher_Base/TeacherBase');
            }
        }else{
            //接收从打分界面传过来的学生id，科目id，老师id，班级id
            $id = $this->request->get();
             $this->assign('id',$id);
            return $this->fetch('Login/achievement');
        }
    }






}